using System;
using System.Collections.Generic;
using System.Text;
using PH.Common;

namespace Hoshimi
{
    public class NeedleBot_AttackState : State
	{
		#region Singleton

		// Fields
		protected static NeedleBot_AttackState instance;

		// Constructor
		protected NeedleBot_AttackState() : base() { }

		// Methods
		public static NeedleBot_AttackState Instance()
		{
			// Uses "Lazy initialization"
			if( instance == null ) 
				instance = new NeedleBot_AttackState();

			return instance;
		}

		#endregion

		public override bool Play( Unit unit ) 
        {
			NeedleBot bot = (NeedleBot) unit;

            bot.SetName("Attack");

            // We cant give order to the bot. We stop
			if (	bot.myNanoDefenderBot.State != NanoBotState.WaitingOrders && 
					bot.myNanoDefenderBot.State != NanoBotState.Defending)
			{
				return true;
			}

			bot.UpdateEnnemyTarget();

            if (!bot.HasEnnemyTarget())
            {
				if(bot.AttackNearestEnnemyDirection())
				{
					return true;
				}

				bot.ChristmasSpirit();
				return true;
            }

            bot.AttackEnnemy();
			return true;
		}
	}
}
